#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# author: maxiao
# date: 2023-03-15 21:42
# description: 测试多线程间的关系


import threading


lock = threading.Lock()

global_score = 100
def update_score(score):
    for i in range(900000):
        lock.acquire()
        global global_score
        global_score = global_score + score
        global_score = global_score - score
        lock.release()

threads = []
print("*" * 25, "Start", "*" * 25)
for i in range(10):
    thread = threading.Thread(target=update_score, args=(i*10,))
    threads.append(thread)

for i in threads:
    i.start()

for i in threads:
    i.join()

print("global_score -----> ", global_score)

